<?php
// app/api/controller/User.php
namespace app\api\controller;

use app\common\controller\ApiController;
use think\Request;

class User extends ApiController
{
    public function profile(Request $request)
    {
        // 检查登录状态
        if (!$this->checkLogin($request)) {
            return json([
                'code' => 401,
                'msg' => '用户未登录',
                'data' => null
            ]);
        }

        // 返回用户信息
        return json([
            'code' => 200,
            'msg' => 'success',
            'data' => $this->getCurrentUser()
        ]);
    }
}
